package com.sbm.domain.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.sbm.springsecurity.SecurityRoleInterface;
import com.sbm.springsecurity.SecurityUserInterface;

import lombok.Data;

@Data
public class UserModel implements SecurityUserInterface {
	private String id;

	private String name;

	private String pwd;

	private Date createTime;

	private Date lastLoginTime;

	private String status;

	private List<RoleModel> roleList;

	@Override
	public String getUsername() {
		return this.name;
	}

	@Override
	public String getPassword() {
		return this.pwd;
	}

	@Override
	public List<SecurityRoleInterface> getRoles() {
		List<SecurityRoleInterface> list = new ArrayList<SecurityRoleInterface>();
		for (RoleModel role : roleList) {
			if (role instanceof SecurityRoleInterface)
				list.add((SecurityRoleInterface) role);
		}
		return list;
	}
}